package com.accp.vehiclecare.action.hzaction;


import com.accp.vehiclecare.biz.hzbiz.cxbiz;
import com.accp.vehiclecare.vo.hzvo.Vehiclebrand;
import com.accp.vehiclecare.vo.hzvo.Vehicletype;
import com.accp.vehiclecare.vo.hzvo.goodssource;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/cx")
public class cxaction {
    @Autowired(required = false)
    private cxbiz cxbiz;
    @GetMapping("show2/{no}/{name}")
    public List<Vehiclebrand> show2(@PathVariable String no, @PathVariable String name) throws Exception {
        return cxbiz.showlist(no,name);
    }
    @PostMapping("add")
    public Map<String, Object> addPerson(@RequestBody Vehiclebrand vehiclebrand) {
        cxbiz.addpp(vehiclebrand);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }
    @GetMapping("showone/{id}")
    public Vehiclebrand showone(@PathVariable Integer id) throws Exception {
        return cxbiz.selectone(id);
    }
    @DeleteMapping("delpp/{id}")
    public Map<String, Object> deletePersonById(@PathVariable Integer id) {
        cxbiz.removepp(id);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }
    @PutMapping("update2/{id}")
    public Map<String, Object> update2(@RequestBody Vehiclebrand vehiclebrand, @PathVariable Integer id) {
        cxbiz.updatepp(vehiclebrand,id);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }

    @GetMapping("show3/{p}/{s}/{name}")
    public PageInfo<Vehicletype> show2(@PathVariable Integer p, @PathVariable Integer s, @PathVariable String name) throws Exception {
        System.out.println(name+"===============");
        return cxbiz.showlist2(p,s,name);
    }
    @GetMapping("showone2/{id}")
    public Vehicletype showone2(@PathVariable Integer id) throws Exception {
        return cxbiz.selectone2(id);
    }
    @DeleteMapping("delpp2/{id}")
    public Map<String, Object> deletePersonById2(@PathVariable Integer id) {
        cxbiz.removepp2(id);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }
    @PutMapping("update3/{id}")
    public Map<String, Object> update2(@RequestBody Vehicletype vehicletype, @PathVariable Integer id) {
        System.out.println(id+"========");
        cxbiz.updatepp2(vehicletype,id);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }
    @PostMapping("add2")
    public Map<String, Object> addPerson2(@RequestBody Vehicletype vehicletype) {
        cxbiz.addcx2(vehicletype);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }
}
